<template>
  <el-table :data="tableData" stripe style="width: 100%">
    <el-table-column prop="product.productId" label="商品ID" width="180" />
    <el-table-column prop="product.productName" label="名称" width="180" />
    <el-table-column prop="count" label="数量" width="180" :value="1"/>
    <el-table-column prop="totalPrice" label="总价格" width="180" />
    <el-table-column prop="purchaseTime" label="日期" width="180" />
  </el-table>
</template>
<script>
import { ref } from 'vue'
import axios from 'axios'
export default {
  name: 'PurchaseHistoryInfo',
  setup () {
    const tableData = ref([])
    // const arr = [
    //   {
    //     id: 1,
    //     name: '娃哈哈',
    //     count: 100,
    //     totalPrice: 100,
    //     date: '2023-01-05 23:38'
    //   },
    //   {
    //     id: 2,
    //     name: '苹果',
    //     count: 300,
    //     totalPrice: 600,
    //     date: '2023-01-05 2023-01-05 23:40'
    //   },
    //   {
    //     id: 3,
    //     name: '挖掘机',
    //     count: 10,
    //     totalPrice: 2000000,
    //     date: '2023-01-05 23:41'
    //   }
    // ]
    // tableData.value = arr
    const getTableData = async () => {
      const result = await axios.get('http://localhost:8080/api/purchase/list')
      tableData.value = result.data.data
      console.log(result.data.data)
    }
    getTableData()
    return {
      tableData
    }
  }
}
</script>
